home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 0769B.ZIP / CL_BASIC.TEM < prev    next >
Text File  |  1987-11-06  |  3KB  |  135 lines

  1. <<title   cl_basic database app.: add, edit, delete, seek, skip>>
  2. <<* Clipper only!  (c) Gregory J. Scott  November 5, 1987 >>
  3. <<* ui programmer template, flat keyed file.>>
  4. *** 
  5. *** Program: {file}.PRG : Add, Edit, Delete, Seek, Skip
  6. *** Generated {date}
  7. *** Program does not maintain a unique key. Warning!
  8. set exact off
  9. set message to 24
  10. mGOTO=1
  11. mSKIP=0
  12. mCHOICE=0
  13. <<ask-for string
  14.   message "Enter key expression initialization value, w/quotes if needed"
  15.   =keyinit
  16.   >>
  17. mKEY={keyinit}
  18. * initialize dbf
  19. << for all dbfs >>
  20. select 0
  21. use {dbf name} index {dbf name}  && presumes that dbf and index have same name
  22. << endfor >>
  23. <<* the next label only generates code if there are input memvars on screen>>
  24. {init all memvars}
  25.  
  26. * initial display
  27.  
  28. <<* here's your screen>>
  29. {display text}
  30.  
  31. * initial record display
  32. do DISPREC
  33.  
  34. do while .t.
  35.  
  36.    @23,05 prompt "Edit" message "Edit this record"             && menu 1
  37.    @23,10 prompt "Add"  message "Add a new record"             && menu 2
  38.    @23,15 prompt "Next" message "move to Next record"          && menu 3
  39.    @23,20 prompt "Prev" message "move to Previous record"      && menu 4
  40.    @23,25 prompt "Top"  message "jump to Top record"           && menu 5
  41.    @23,30 prompt "Bott" message "jump to Bottom record"        && menu 6
  42.    @23,35 prompt "Skip" message "Skip +/- n records"           && menu 7
  43.    @23,40 prompt "Key"  message "use a Key to seek a record"   && menu 9
  44.    @23,45 prompt "Del"  message "Delete this record"           && menu 10
  45.    @23,50 prompt "Quit" message "Quit this screen"             && menu 11
  46.    @23,60 say    left(time(),5)
  47.    @23,66 say    iif(deleted(),"DELETED","       ")
  48.    menu to mCHOICE                                              
  49.  
  50.    do case
  51.       case mCHOICE = 1
  52.          do EDITREC
  53.       case mCHOICE = 2
  54.          do ADDREC
  55.       case mCHOICE = 3
  56.          do SKIPREC with 1
  57.       case mCHOICE = 4
  58.          do SKIPREC with -1
  59.       case mCHOICE = 5
  60.          goto top
  61.       case mCHOICE = 6
  62.          goto bottom
  63.       case mCHOICE = 7
  64.          do SKIPREC
  65.       case mCHOICE = 8
  66.          do KEYREC
  67.       case mCHOICE = 9 
  68.          do DELREC
  69.       case mCHOICE = 10
  70.          exit
  71.    endcase
  72.    do DISPREC
  73.  
  74. enddo
  75. return
  76.  
  77. * skip n records       -------------------------------------------------------
  78. proc SKIPREC
  79. parameters mSKIP
  80. if pcount()=0
  81.    mSKIP=0
  82.    @24,0 clear
  83.    @24,5 say "number of records to skip: " get mSKIP picture "9999"
  84.    read
  85. endif
  86. skip mSKIP
  87. do case
  88.    case bof()
  89.       goto top
  90.    case eof()
  91.       goto bottom
  92. endcase
  93. return
  94.  
  95. proc KEYREC
  96. mGOTO=recno()
  97. @24,0 clear
  98. @24,5 say "Key to seek: " get mKEY
  99. read
  100. seek rtrim(mKEY)
  101. if eof() .and. .not. bof()
  102.    GOTO mGOTO
  103. endif
  104. return
  105.  
  106. * edit record          -------------------------------------------------------
  107. proc EDITREC
  108. {get all fields}
  109. read
  110. return
  111.  
  112. * delete record        -------------------------------------------------------
  113. proc DELREC
  114. if .not. deleted()
  115.    delete
  116. else
  117.    recall
  118. endif
  119. return
  120.  
  121. * append record        -------------------------------------------------------
  122. proc ADDREC
  123. append blank
  124. do DISPREC
  125. do EDITREC
  126. return
  127.  
  128. * basic record display  ------------------------------------------------------
  129. proc DISPREC
  130. {say all variables}
  131. {get all variables}
  132. clear gets
  133. return
  134.  
  135. * EOF {file}.prg